var mygrid;
$(function() {
	mygrid = $("#list").jqGrid({
		url : "admin/securole/secu-role!datalist",
		datatype : "json",
		mtype : 'GET',
		colNames : [ '查看', '优先级' , '管理' ],
		colModel : [ {
			name : 'name',
			index : 'name',
			width : 200,
			formatter : viewFormater
		},{
			name:"priority",
			index:"priority"
			
		},{
			name : 'name',
			index : 'name',
			width : 200,
			formatter : removeFormatter
		}, ],
		pager : '#pager',
		rowNum : 10,
		rowList : [ 10, 20, 30 ],
		sortname : 'priority',
		sortorder : 'asc',
		viewrecords : true,
		caption : '系统权限分配表',
		width : '600',
		height : '300',
		jsonReader : {
			repeatitems : false,
			id : "0"
		}
	});
	mygrid.jqGrid("navGrid", "#pager", {
		edit : false,
		add : false,
		del : false,
		search : false
	});
	mygrid.jqGrid("navButtonAdd", "#pager", {
		onClickButton : function() {
			saveAcegiRole();
		},
		buttonicon : "ui-icon-newwin",
		caption : "添加",
		id : "newGroup"
	});
	mygrid.jqGrid("navButtonAdd", "#pager", {
		onClickButton : function() {
			var url = "admin/securole/secu-role!priority";
			doGet(url);
		},
		buttonicon : "ui-icon-newwin",
		caption : "优先级",
		id : "uppriory"
	});

});
function viewFormater(cellvalue, options, rowObject) {
	var url = "admin/securole/secu-role!get?bean.name="	+ cellvalue;
	var link = $(getAjaxLink(url, rowObject['description']));
	return $("<span></span>").append(link).html();

}
function removeFormatter(cellvalue, options, rowObject) {
	var url = "admin/securole/secu-role!remove?bean.name="+cellvalue;
	var link = $("<a><img style='border:none' src='"+sbase+"images/removeme.gif'/></a>");
	link.attr("href","javascript:removeOne('"+url+"');");
	return $("<span></span>").append(link).html();
}
function doActionWork(url, eid) {
	doAjaxLoad(url, {
		"workflowId" : eid,
		"userView" : true
	});
}
function saveAcegiRole() {
	doAjaxLink('admin/securole/edit?operation=add');
}
function removeOne(url){
	doSubmit(url,{},function(){
		mygrid.trigger("reloadGrid");
	});
	
}